import Storage from "./Storage"
import { defineStore } from 'pinia'
import { ref, reactive } from 'vue'
const TokenKey = 'Token'

export const UseUserStore = defineStore('User', () => {
    // 推荐用于完整类型推断的箭头函数
    const token = ref(Storage.Get(TokenKey));
    const UserInfo = reactive({});

    const SetToken = function (value) {
        token.value = value;
        Storage.Set(TokenKey, value)
    }

    const Logout = function () {
        token.value = null;
        Storage.Remove(TokenKey);
    };
    return { token, SetToken, Logout }
})